﻿/*
 * Autore: Artur Tolstenco
 */

using System;

namespace RecipesManager.MainControls.RecipeSubControls
{
    public class IngredientFromRecipe
    {
        public IngredientFromRecipe(string name, string notes = "", double quantity = 0, string measure = "")
        {
            Name = name;
            Notes = notes;
            Quantity = quantity;
            Measure = measure;
        }

        public String Name { get; private set; }
        public String Notes { get; set; }

        public String QuantityString
        {
            get { return Quantity + " " + Measure; }
        }

        public Double Quantity { get; set; }
        public String Measure { get; set; }


        protected bool Equals(IngredientFromRecipe other)
        {
            return string.Equals(Name, other.Name);
        }

        public override bool Equals(object obj)
        {
            if (ReferenceEquals(null, obj)) return false;
            if (ReferenceEquals(this, obj)) return true;
            if (obj.GetType() != this.GetType()) return false;
            return Equals((IngredientFromRecipe) obj);
        }

        public override int GetHashCode()
        {
            return Name.GetHashCode();
        }
    }
}
